package com.example.controller;
import com.example.common.Result;
import com.example.common.ResultUtils;
import com.example.dto.UserPageQuery;
import com.example.page.PageResult;
import com.example.po.UserPO;
import com.example.service.IUserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/*
@description:aop简化mybatis分页查询
@ClassName PageQueryController
@author chen
@create 2025-07-15 14:15
@Version 1.0
*/
@RestController
@RequestMapping("/user")
public class PageQueryController
{
    @Resource
    private IUserService userService;


    @GetMapping("/selectPage")
    public Result<PageResult<UserPO>> selectPage(@RequestParam("pageNum") int pageNum, @RequestParam("pageSize") int pageSize)
    {
        PageResult<UserPO> page = this.userService.selectPage(pageNum, pageSize);
        return ResultUtils.success(page);
    }

    @GetMapping("/selectPageNew")
    public Result<PageResult<UserPO>> selectPageNew(@RequestParam("pageNum") int pageNum, @RequestParam("pageSize") int pageSize)
    {
        PageResult<UserPO> page = this.userService.selectPageNew(pageNum, pageSize);
        return ResultUtils.success(page);
    }

    @GetMapping("/userPage")
    public Result<PageResult<UserPO>> userPage(UserPageQuery query)
    {
        PageResult<UserPO> page = this.userService.userPage(query);
        return ResultUtils.success(page);
    }
}
